package com.im.service.controller;

import com.im.service.controller.request.ImUserDTO;
import com.im.service.infra.entity.ImUser;
import com.im.service.service.ImUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.time.LocalDateTime;

@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
public class ImUserController {
    private final ImUserService imUserService;

    @PostMapping
    public Mono<ImUser> registry(@RequestBody ImUserDTO imUser) {
        return imUserService.saveOrUpdate(new ImUser(imUser.getId(), LocalDateTime.now(), null));
    }
}
